/*
 * @Description:
 * @Author: 徐金星
 * @Date: 2020-09-29 10:55:02
 */
import { Loading } from "element-ui";
let loading = "";
function startLoading() {
  // 使用Element loading-start 方法
  loading = Loading.service({
    lock: true,
  });
}
function endLoading() {
  // 使用Element loading-close 方法
  loading.close();
}
// 防止loading 重复调用
let needLoadingRequestCount = 0;
export function showFullScreenLoading() {
  if (needLoadingRequestCount === 0) {
    startLoading();
  }
  needLoadingRequestCount++;
}

export function tryHideFullScreenLoading() {
  if (needLoadingRequestCount <= 0) return;
  needLoadingRequestCount--;
  if (needLoadingRequestCount === 0) {
    endLoading();
  }
}
